package learn_concurrent._1;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class T14 {
	final static Logger logger = LoggerFactory.getLogger(T14.class);

	public static void main(String[] args) {
		test1();
	}

	private static void test1() {
//		logger.debug("start...");
		Thread t1 = new Thread(() -> {
//			logger.debug("start......");
			try {
				Thread.sleep(5000);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
//			logger.debug("end......");
		});
		
		t1.start();
		try {
			Thread.sleep(3000);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		t1.interrupt();
		try {
			Thread.sleep(100); // 等待一会 isInterrupted() 的值才会正确
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
//		boolean isInterrupted = t1.isInterrupted();
		logger.debug("isInterrupted = {}", t1.isInterrupted());
//		logger.debug("end...");
		System.out.println(t1.isInterrupted());
	}

}
